<?php

// -----------------------------------------------------------------------------

include "global/functions.php";
include "config/config.php";
include "global/globalAuth.php";
include "createDBIfNotExists.php";

// -----------------------------------------------------------------------------

if (empty($_GET['date'])) {
    exit("需要传入有效的数据。");
}

$startDate = $_GET['date'];

// -----------------------------------------------------------------------------

$dateToInsert = [];
// 把输入的当天日期也加进来
$dateToInsert[] = $startDate;

$n = 1;
while (true) {
    $dateToInsert[] = getTheDate($startDate, "+", pow(2,($n - 1)));
    $n += 1;
    if ($n > $reviewTimes) {
        break;
    }
}

?>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>相关日期</title>
    <link rel="stylesheet" href="resources/bootstrap-4.3.1-dist/css/bootstrap.min.css">
</head>
<body>

<!-- ----------------------------------------------------------------------- -->

<?php include 'global/globalNavBar.php'; ?>

<!-- ----------------------------------------------------------------------- -->

<!--container-->
<div class="container mt-2 mb-2">

    <div class="list-group">

        <?php

            $counter = 1;
            foreach ($dateToInsert as $date) {

                if ($date == $startDate) {

                    echo <<<BBB
                        <a href="viewByDate.php?date=$date" class="list-group-item list-group-item-action">$date 【始记】</a>
                    BBB;

                } else {

                    echo <<<BBB
                        <a href="viewByDate.php?date=$date" class="list-group-item list-group-item-action">$date 【第{$counter}轮复习】</a>
                    BBB;

                    $counter += 1;

                }

            }

        ?>

    </div>

</div>
<!--container-->

<!-- ----------------------------------------------------------------------- -->
<script src="resources/jquery/jquery-3.4.0.min.js"></script>
<script src="resources/bootstrap-4.3.1-dist/js/bootstrap.min.js"></script>
<!-- ----------------------------------------------------------------------- -->

</body>
</html>
